package com.sh.caryr.erp.custmz;

import java.util.HashSet;
import java.util.Set;

public class UserAuthorityCont {

	public Set<String> data = new HashSet<String>();
	public static final String  seperator = "_";
	public static final String  authAll = "all";
	public UserAuthorityCont(){}
	
	public void setData(Set<String> data) {
		this.data = data;
	}
	
	public boolean put(String auth){
		return data.add(auth);
	}
	public static UserAuthorityCont allAuthsData(){
		UserAuthorityCont authContainer = new UserAuthorityCont();
		authContainer.put("testObj_read_field_all");
		return authContainer;
	}
	
	public boolean check(String obj,String actvt,String checkPoint,String value){
		String auth = obj + seperator + actvt + seperator + checkPoint + seperator + value;
		boolean result = check(obj + seperator + actvt + seperator + checkPoint + seperator + authAll);
		if(result){
			return true;
		}
		return check(auth);
	}
	
	public boolean check(String auth){
		return data.contains(auth);
	}

}